// The form contains fields for many pagiantion optiosn so you can 
// quickly see the resuluts of the different options.
// This function creates an option object for the pagination function.
// This will be be unnecessary in your application where you just set
// the options once.
$(function() {
		var items_on_page = 30;
		var pages_step = 5;
		
		get_data(1, 30);
		$.ajax({
			type: "POST",
			url: "/university/stores_total",
			data: {
			university_id: $("#university_id").val(),
			cat_id: $("#cat_id").val(),
			type: "get"},
			success: function(total)
			{
				$("#paging").jpaging({
					all_items_num: total,
					callback: get_data,
					items_on_page: items_on_page,
					pages_step: pages_step
				});
			}
		});

		function get_data(start_index, end_index){
			start_index = start_index - 1;
			end_index = end_index - 1;

			$.ajax({
				type: "POST",
				url: "/university/stores_paging",            
				data: {start_index: start_index,
				end_index: end_index,
				university_id: $("#university_id").val(),
				cat_id: $("#cat_id").val(),
				type: "get"},
				success: function(html)
				{                  
					$("#demo_tbl").html(html);
					$('html, body').animate({ scrollTop: 0 }, 'slow');
				}
			});			
		}

});
